<?php
include_once("../../../common/module/checkA.php");
include_once("../../../../config.php");
include_once("../controller/collect.php");
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php include ROOT_PATH_.'/controller/common/module/head.php'; ?>

    <style type="text/css">
        .indexinfo .box{
            height: auto;
        }
    </style>
</head>

<body>

<div id="topbar">
    <?php include ROOT_PATH_.'/controller/common/module/topbar.php'; ?>
</div>

<div id="container" class="<? echo $system_part ?>">

    <div id="maincontent">

        <div id="sidebar">
            <?php include ROOT_PATH_.'/controller/common/module/sidebar.php'; ?>
        </div>


        <div id="content">
            <?php $page_title = '订单汇总'; ?>
            <?php include ROOT_PATH_ . '/controlbase/module/mod-page-title.php'; ?>

            <?
//TODO 在时间段选择处，默认读取现在搜索的时间段。当天?>

<!--    <blockquote class="layui-elem-quote">-->
<!--        1.页面默认统计当天的数据。<br/>-->
<!--        2.更多时间段汇总可在根据实际情况在搜索框调整。-->
<!--    </blockquote>-->


    <div class="select-box clearfix layui-form">
        <form action="collect.php" >

            <div class="layui-form-item">
                <label class="layui-form-label">时间</label>

                <div class="layui-input-block">
                    <input type="text" name="select_startday" placeholder="请输入开始时间" autocomplete="off" class="layui-input"  onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" style="float: left; width: 112px" value="<?if($_REQUEST['select_startday']){echo $_REQUEST['select_startday'] ;} ?>" >

                    <span style="float: left;margin: 0 4px; line-height: 30px;">-</span>

                    <input type="text" name="select_endday" placeholder="请输入结束时间" autocomplete="off" class="layui-input" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"  style="float: left; width:112px" value="<?if($_REQUEST['select_endday']){echo $_REQUEST['select_endday'] ;} ?>"  >
                    <input type="hidden" name="nav-itemed"  value="order" >
                    <input type="hidden" name="sys_part"  value="order" >
                </div>
            </div>

            <button class="layui-btn  layui-btn-sm" name="search"  value="查找" ><i class="layui-icon">&#xe615;</i> 查找</button>

<!--            <button class="layui-btn  layui-btn-sm" name="search"  value="导出汇总" ><i class="layui-icon">&#xe615;</i> 导出汇总</button>-->

            <a class="layui-btn  layui-btn-sm" href="collect.php?sys_part=<?php echo $system_part?>" ><i class="layui-icon">&#x1006;</i> 重置</a>
        </form>

        <br class="clearfloat"/>
    </div>


<!-- 用$system_part .list_boxes来控制来到确认板块信息显示-->
<div class="list-box">

<!--      --><?php //include 'mod-collect.php'; ?>
    <br class="clearfloat"/>

    <ul class="indexinfo">

        <li>
            <div class="box">
                <h6><i class="fa fa-bar-chart-o" aria-hidden="true"></i>订单信息</h6>
                <hr class="layui-bg-green">
                <div class="content">

                    <?
                    $p['array']=$orderlist;
                    $p['condition_key']="status";
                    $p['condition_value']="待确认";
                    $p['target']='price';

                    $result=sum_with_key_by_value_in_2d_array($p);
                    ?>
                    <div><b>待确认：</b> <?echo $result['num']?> 单 / <?echo $result['sum']?>元</div>

                    <?$p['condition_value']="待发货";$result=sum_with_key_by_value_in_2d_array($p)?>
                    <div><b>待发货：</b> <?echo $result['num']?> 单 / <?echo $result['sum']?>元</div>

                    <?$p['condition_value']="已发货";$result=sum_with_key_by_value_in_2d_array($p)?>
                    <div><b>已发货：</b> <?echo $result['num']?> 单 / <?echo $result['sum']?>元</div>

                    <?$p['condition_value']="待收款";$result=sum_with_key_by_value_in_2d_array($p)?>
                    <div><b>待收款：</b> <?echo $result['num']?> 单 / <?echo $result['sum']?>元</div>

                    <?$p['condition_value']="已完成";$result=sum_with_key_by_value_in_2d_array($p)?>
                    <div><b>已完成：</b> <?echo $result['num']?> 单 / <?echo $result['sum']?>元</div>

                    <?$p['condition_value']="已取消";$result=sum_with_key_by_value_in_2d_array($p)?>
                    <div><b>已取消：</b> <?echo $result['num']?> 单 / <?echo $result['sum']?>元</div>
                </div>
            </div>
        </li>

        <li>
            <div class="box">
                <?
                $p['orderby']="sums";
                $p['sum']="number";
                $p['count']="product_nid";
                $p['table']=$table_prefix."order_detail";
                $p['groupby']="product_nid";
                $p['orderby']="sums";
                $p['orders']="desc";
                $p['limit']="20";
                $p['log']="0";
                $p['date']=  $select_str;
                $list=count_sum_groupby($p);
                ?>
                <h6><i class="fa fa-shopping-cart" aria-hidden="true"></i>销量排行</h6>
                <hr class="layui-bg-green">
                <ol  class="content">
                    <? foreach ($list as $k => $v) {?>
                        <li><?echo $k+1 ?> : <?echo $v['name']?>  <span style="float: right"><?echo $v['sums']?></span>  </li>
                        <?;}?>
                </ol>
            </div>
        </li>

        <li>
            <div class="box">
                <?
                $p['orderby']="sums";
                $p['sum']="price";
                $p['count']="product_nid";
                $p['table']=$table_prefix."order_detail";
                $p['groupby']="product_nid";
                $p['orderby']="sums";
                $p['orders']="desc";
                $p['limit']="20";
                $p['log']="0";
                $p['date']=  $select_str;
                $list_price=count_sum_groupby($p);

                ?>
                <h6><i class="fa fa-dollar" aria-hidden="true"></i>销售额排行</h6>
                <hr class="layui-bg-green">
                <ol  class="content">
                    <? foreach ($list_price as $k => $v) {?>
                        <li><?echo $k+1 ?> : <?echo $v['name']?>  <span style="float: right"><?echo $v['sums']?></span>  </li>
                        <?;}?>
                </ol>

            </div>
        </li>

        <li>
            <div class="box">
                <?
                $p['orderby']="sums";
                $p['sum']="price";
                $p['count']="nid";
                $p['table']=$table_prefix."order_list";
                $p['groupby']="agent";
                $p['orderby']="sums";
                $p['orders']="desc";
                $p['limit']="20";
                $p['log']="0";
                $p['date']=  $select_str;
                $list_agent=count_sum_groupby($p);

                $emp_rank_array=transform_2darray_in_1darray_number_as_key($list_agent,"agent");
                $emp_rank_str=implode($emp_rank_array,"','");

                $emp_rank=select_lines_items($table_prefix."employee","","name,nid","nid in ('".$emp_rank_str."')","");
                $emp_list=transform_2darray_in_1darray_with_new_key($emp_rank,"nid","name");


                ?>
                <h6><i class="layui-icon">&#xe626;</i>销售排行</h6>
                <hr class="layui-bg-green">
                <ol  class="content">
                    <? foreach ($list_agent as $k => $v) {?>
                        <li><?echo $k+1 ?> : <?echo $emp_list[$v['agent']]?>  <span style="float: right"><?echo $v['sums']?></span> </li>
                        <?;}?>
                </ol>

            </div>
        </li>

        <li>
            <div class="box">
                <h6><i class="fa fa-map-o" aria-hidden="true"></i>地区分布</h6>
                <hr class="layui-bg-green">
                <div  class="content">
                    <div  class="content">
                        <div>暂无数据...</div>
                    </div>
                </div>

            </div>
        </li>
    </ul>
</div>

<!--list-box end-->
</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>

<!--删除box-->
<?php include '../module/deletebar.php'; ?>
<!--删除box end-->

<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?> </body>
</html>
